class Segments6 extends egret.Sprite {
    private slider0: SimpleSlider
    private slider1: SimpleSlider
    private segment0: Segment
    private segment1: Segment
    public constructor() {
        super()
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this)
    }

    private onAddToStage(event: egret.Event) {
        this.segment0 = new Segment(100, 20)
        this.addChild(this.segment0)
        this.segment0.x = 100
        this.segment0.y = 120

        this.segment1 = new Segment(100, 20)
        this.addChild(this.segment1)
        this.segment1.x = this.segment0.getPin().x
        this.segment1.y = this.segment0.getPin().y

        this.slider0 = new SimpleSlider(-90, 90, 0)
        this.slider0.x = 320
        this.slider0.y = 20
        this.addChild(this.slider0)
        this.slider0.addEventListener(egret.Event.CHANGE, this.onChange, this)

        this.slider1 = new SimpleSlider(-160, 0, 0)
        this.slider1.x = 340
        this.slider1.y = 20
        this.addChild(this.slider1)
        this.slider1.addEventListener(egret.Event.CHANGE, this.onChange, this)
    }

    private onChange() {
        this.segment0.rotation = this.slider0.value
        this.segment1.rotation = this.slider1.value + this.segment0.rotation
        this.segment1.x = this.segment0.getPin().x
        this.segment1.y = this.segment0.getPin().y
    }
}